#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

#这种模式是直接在构建镜像的内部编译发布dotnet项目。
#注意下容器内输出端口是8081
#如果你想先手动dotnet build成可执行的二进制文件，然后再构建镜像，请看.Api层下的dockerfile。


FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["Ebase.Api/Ebase.Api.csproj", "Ebase.Api/"]
COPY ["Ebase.Extensions/Ebase.Extensions.csproj", "Ebase.Extensions/"]
COPY ["Ebase.Tasks/Ebase.Tasks.csproj", "Ebase.Tasks/"]
COPY ["Ebase.IServices/Ebase.IServices.csproj", "Ebase.IServices/"]
COPY ["Ebase.Model/Ebase.Model.csproj", "Ebase.Model/"]
COPY ["Ebase.Common/Ebase.Common.csproj", "Ebase.Common/"]
COPY ["Ebase.Services/Ebase.Services.csproj", "Ebase.Services/"]
COPY ["Ebase.Repository/Ebase.Repository.csproj", "Ebase.Repository/"]
COPY ["Ebase.EventBus/Ebase.EventBus.csproj", "Ebase.EventBus/"]
RUN dotnet restore "Ebase.Api/Ebase.Api.csproj"
COPY . .
WORKDIR "/src/Ebase.Api"
RUN dotnet build "Ebase.Api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Ebase.Api.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
EXPOSE 8081 
ENTRYPOINT ["dotnet", "Ebase.Api.dll"]